SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "SCRIPT DIR: $SCRIPT_DIR"

sudo apt update -y && sudo apt upgrade -y
sudo apt install -y git vim wget curl python3 openssh-server
mkdir -p ~/Projects/{Mine,Company,Forked,StdEnv,Web,Study,PlayGroup}/

# if id_rsa is not exist, create it
if [ ! -f ~/.ssh/id_rsa ]; then
    # ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N ""
    ssh-keygen -t ecdsa -f ~/.ssh/id_rsa -C "$USER@$HOSTNAME" -N '' <<<y
    cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
    chmod 0400 ~/.ssh/id_rsa{,.pub}
fi

bash check_vcs_key.sh

if [ ! -d ~/Projects/StdEnv/stdenv ]; then
    git clone git@gitee.com:stdenv/stdenv ~/Projects/StdEnv/stdenv
fi

if [ ! -d ~/Projects/StdEnv/scripts ]; then
    git clone git@gitee.com:stdenv/scripts ~/Projects/StdEnv/scripts
fi

if [ ! -d ~/Projects/StdEnv/aliases ]; then
    git clone git@gitee.com:stdenv/aliases ~/Projects/StdEnv/aliases
fi
